﻿(function(global, $, amplify) {
    // Bootstrapper JavaScript file for TimberSmart
    var ts = global.ts = global.ts || { }

    // Startup
    $(document).ready(function () {

        $(document).on("click", "#loadUsers", function () {
            amplify.request("FindAllUsers", function (response) {
                var users = [];

                $.each(response.Data, function () {
                    var user = new global.ts.userViewModel(this);
                    users.push(user);
                });

                ts.viewModels.users = ko.observableArray(users)

                ko.applyBindings(ts);
            });
        });

        $(document).on("click", ".editButton", function () {
            var groupId = $(this).attr("param");

            $(".editGroup" + groupId).replaceWith(function () {
                return "<input type=\"text\" value=\"" + $(this).text() + "\" />";
            });
        });
    });

})(this, jQuery, amplify);
